<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  // 刷新的时候重新获取cookies的数据
  created () {
    this.$store.commit('addMenu', this.$router)
    // 添加tag
    this.getTag()
  },
  methods: {
    getTag () {
      const path = this.$route.path
      this.menuList.some(item => {
        if (!item.children) {
          if (item.path === path) {
            this.$store.commit('selectMenu', item)
          }
        } else {
          item.children.some(child => {
            if (child.path === path) {
              this.$store.commit('selectMenu', child)
            }
          })
        }
      })
    }
  },
  computed: {
    ...mapState({
      menuList: state => state.tabs.menu
    })
  },
}
</script>
<style lang="less">
@import url('./assets/css/base.less');
</style>
